﻿#region Usings

using System.Linq;
using KanbanBoard.Server.Command.DomainModel;
using KanbanBoard.Tests.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace KanbanBoard.Tests.Server.Utils.DSL {
    public class TaskBoardAssertionExpressionBuilder {
        private readonly TaskBoard actualBoard;

        public TaskBoardAssertionExpressionBuilder(TaskBoard actualBoard) {
            this.actualBoard = actualBoard;
        }

        public void LooksLike(string expected) {
            var expectedBoard = expected.BasicParse();

            CollectionAssert.AreEqual(expectedBoard.Keys, actualBoard.Columns().Select(_ => _.Name()).ToList(),
                                      "Columns do not match");

            foreach (var column in actualBoard.Columns()) {
                CollectionAssert.AreEqual(expectedBoard[column.Name()], column.Tasks().Select(_ => _.Description()).ToList(),
                                          "Tasks in {0} column do not match", column.Name());
            }
        }
    }
}